package com.example.bbs.bean;

import android.os.Parcel;
import android.os.Parcelable;

public class User {

    private int id = -1; // 初始值为 -1。不存在编号为 -1 的用户。
    private String name="";
    private String email="";
    private String password="";
    private String introduction="";
    private String avatarUrl="";
    private String token="";

    public User() {}

    public User(int id, String name, String introduction) {
        this.id = id;
        this.name = name;
        this.introduction = introduction;
    }

    public User(int id, String name, String email, String password,  String introduction, String avatarUrl, String token) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.password = password;
        this.introduction = introduction;
        this.avatarUrl = avatarUrl;
        this.token = token;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(name);
        dest.writeString(email);
        dest.writeString(password);
        dest.writeString(introduction);
        dest.writeString(avatarUrl);
        dest.writeString(token);
    }

    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(
                    source.readInt(),                       // id
                    source.readString(),                    // name
                    source.readString(),                    // email
                    source.readString(),                    // password
                    source.readString(),                    // introduction
                    source.readString(),                    // avatarUrl
                    source.readString()                    // token
            );
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}

